# -*- coding:utf-8 -*-
from django.db import models

from hbitdb.models import IDC


class NetworkAccess(models.Model):
    bumen = models.CharField(u"部门", max_length=64)
    name = models.CharField(u"姓名", max_length=64)
    erp = models.CharField(u"ERP", max_length=64)
    mail = models.EmailField(u"邮箱")
    telphone = models.CharField(u"手机", max_length=11)
    weizhi = models.CharField(u"位置", max_length=128)
    hostname = models.CharField(u"计算机名", max_length=15)
    description = models.TextField(u"权限描述")
    usetime = models.DateField(u'开始时间')
    dqtime = models.DateField(u'结束时间')

    class Meta:
        verbose_name = u"网络权限开通记录"
        verbose_name_plural = verbose_name


'''
网络故障记录
'''


class NetwokFault(models.Model):
    cbmc = models.CharField(u"仓储名称", max_length=64)
    qstime = models.DateTimeField(u'开始时间')
    jztime = models.DateTimeField(u'结束时间')
    cxtime = models.PositiveSmallIntegerField(u"持续时间(分钟)")
    gzms = models.CharField(u"故障描述", max_length=256)
    gzyy = models.CharField(u"故障原因", max_length=64)
    gzjjbm = models.CharField(u"故障解决部门", max_length=64)
    gzjjr = models.CharField(u"故障解决人", max_length=64)
    jjbf = models.CharField(u"解决办法", max_length=256)
    bgr = models.CharField(u"报告人", max_length=64)
    beizhu = models.TextField(u"备注", blank=True, null=True)

    class Meta:
        verbose_name = u"故障记录"
        verbose_name_plural = verbose_name


WX_BM = (
    (0, "办公室"),
    (1, "仓储部"),
    (2, "仓储管理部"),
    (3, "大件运营部"),
    (4, "公共事务部"),
    (5, "行政部"),
    (6, "华北区大客户部"),
    (7, "华北区防损部"),
    (8, "配送管理部"),
    (9, "企业IT部"),
    (10, "人力资源部"),
    (11, "山东省区分公司"),
    (12, "商城财务部"),
    (13, "市场部"),
    (14, "售后综合管理部"),
    (15, "通讯业务一部"),
    (16, "运营管理部"),
    (17, "综合部")
)

WX_GZ_LX = (
    (0, "BIOS自检不通过"),
    (1, "CPU风扇故障"),
    (2, "CPU故障"),
    (3, "按键损坏"),
    (4, "屏幕故障"),
    (5, "屏幕排线故障"),
    (6, "扫描头故障"),
    (7, "打印机齿轮故障"),
    (8, "打印机传感器故障"),
    (9, "打印机搓纸轮故障"),
    (10, "打印机断针"),
    (11, "打印机漏粉"),
    (12, "打印机马达故障"),
    (13, "打印机字库故障"),
    (14, "点钞机验钞故障"),
    (15, "电源公章"),
    (16, "网卡故障"),
    (17, "主板故障"),
    (18, "人为损坏"),
    (19, "其他"),
)

SB_NAME = (
    (0, "打印机"),
    (1, "笔记本"),
    (2, "台式机"),
    (3, "显示器"),
    (4, "电脑一体机"),
    (5, "PDA"),
    (6, "扫描枪"),
    (7, "点钞机"),
)

SB_PINGPAI = (
    (0, "爱普生"),
    (1, "斑马"),
    (2, "戴尔"),
    (3, "得力"),
    (4, "东芝"),
    (5, "宏碁"),
    (6, "华硕"),
    (7, "惠普"),
    (8, "佳能"),
    (9, "科密"),
    (10, "联想"),
    (11, "MOTO"),
    (12, "七喜"),
    (13, "齐心"),
    (14, "清华同方"),
    (15, "实达"),
    (16, "兄弟"),
    (17, "讯宝"),
    (18, "优派"),
    (19, "神舟"),
)

BX_ZT = (
    (0, "是"),
    (1, "否"),
)

WX_ZT = (
    (0, "已送修"),
    (1, "待送修"),
    (2, "修复完成"),
)

JD_YJ = (
    (0, "建议维修"),
    (1, "建议报废"),
)


class HardRepair(models.Model):
    tbr = models.CharField(u"提报人", max_length=6,
                           help_text="本人姓名")
    bxdate = models.DateField(u'报修日期')
    bumen = models.SmallIntegerField(u"部门", choices=WX_BM)
    sqr = models.CharField(u"申请人", max_length=8)
    guzhang = models.SmallIntegerField(u"故障类型", choices=WX_GZ_LX)
    sbname = models.SmallIntegerField(u"设备名称", choices=SB_NAME)
    sbpinpai = models.SmallIntegerField(u"品牌名称", choices=SB_PINGPAI)
    xinghao = models.CharField(u"规格型号", max_length=15)
    sn = models.CharField(u"产品序列号", max_length=15)
    code = models.CharField(u"资产编码", max_length=15)
    bx = models.SmallIntegerField(u"是否在保", choices=BX_ZT)
    gzmiaoshu = models.CharField(u"故障描述", max_length=512)
    wxzt = models.SmallIntegerField(u"维修状态", choices=WX_ZT)
    jdyj = models.SmallIntegerField(u"鉴定意见", choices=JD_YJ)
    xfdate = models.DateField(u'修复日期')
    wxje = models.PositiveIntegerField(u"维修金额(元)")
    beizhu = models.TextField(u"备注", blank=True, null=True)
    class Meta:
        verbose_name = u"维修数据"
        verbose_name_plural = verbose_name


"""
定义机房巡查表
"""
UPS_ZT = (
    (0, "正常"),
    (1, "故障"),
    (2, "无"),
)

SIM_ZT = (
    (0, "无"),
    (1, "正常"),
    (2, "停机"),
)


class RoomPatrol(models.Model):
    jifang = models.ForeignKey(IDC, verbose_name=u'机房名称',
                               help_text=u"列表中没有的,请进入'固资管理-机房'中添加 ")
    datatime = models.DateTimeField(u"日期时间")
    xcname = models.CharField(u"巡检人", max_length=15)
    wendu = models.PositiveSmallIntegerField(u"温度(摄氏度)")
    shidu = models.PositiveSmallIntegerField(u"湿度(百分比)")
    ups = models.SmallIntegerField(u"UPS状态", choices=UPS_ZT)
    sim = models.SmallIntegerField(u"SIM卡状态", choices=SIM_ZT)
    beizhu = models.TextField(u"备注", blank=True, null=True)

    class Meta:
        verbose_name = u"机房巡查"
        verbose_name_plural = verbose_name




        # class Weekly(models.Model):
        #   fujian = models.FileField(upload_to = './upload/')

        #  class Meta:
        #     verbose_name = u"文件上传测试"
        #    verbose_name_plural = verbose_name